﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="first.aspx.cs" Inherits="www.pages.first" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="../plugins/layer/theme/default/layer.css" rel="stylesheet" />
    <link href="../css/lanai-ui.min.css" rel="stylesheet" />
</head>
<body>
    <section class="content">
        <form id="form1" runat="server">
            <div class="row">
                <div class="col-sm-3">
                    <div class="box box-widget no-shadow">
                        <div class="box-header with-border">
                            <span class="text-sm">最近使用项目</span>
                            <div class="box-tools">
                                <a id="btnList" class="btn btn-box-tool"><i class="fa fa-ellipsis-h"></i></a>
                            </div>
                        </div>
                        <div class="box-body">
                            <asp:Repeater ID="list" runat="server">
                                <HeaderTemplate>
                                     <ul class="todo-list">
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <li>
                                    <span class="text"><%#Eval("project_name") %></span>
                                    <div class="tools">
                                        <i class="fa fa-edit" onclick="openProject('<%#Eval("project_id") %>')"></i>
                                        <i class="fa fa-play text-green" onclick="run('<%#Eval("project_id") %>')"></i>
                                    </div>
                                </li>
                                </ItemTemplate>
                                <FooterTemplate>
                                    </ul>
                                </FooterTemplate>
                            </asp:Repeater>

                        </div>
                        <div class="box-footer">
                            <div class="pull-right">
                                <a href="#" id="btnNew" class="btn btn-default btn-flat"><i class="fa fa-plus"></i>新建项目</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </section>
    <script src="../js/jquery.min.js"></script>
    <script src="../plugins/layer/layer.js"></script>
    <script src="../js/common.js"></script>
    <script src="../js/lanai-ui.min.js"></script>
    <script type="text/javascript">
        $(function () {
            parent.setProject("");
            $("#btnNew").click(function () {
                layer.open({
                    type: 2,
                    title: "新建项目",
                    shadeClose: false,
                    shade: 0.6,
                    maxmin: false,
                    scrollbar: false,
                    area: ["600px", "345px"],
                    content: "/pages/project/new.aspx"
                });
            });

            $("#btnList").click(function () {
                layer.open({
                    type: 2,
                    title: "打开项目",
                    shadeClose: false,
                    shade: 0.6,
                    maxmin: true,
                    scrollbar: false,
                    area: ["700px", "500px"],
                    content: "/pages/project/list.aspx"
                });
            });
        })

        function run(p) {
            RunProject(p);
        }

        function openProject(p) {
            parent.setProject(p);
            location.href="/pages/project/project.aspx?id="+p;
        }

        function doSaveProject(id,name, comment) {
            var param = {};
            param["function_type"] = "addProject";
            param["id"] = id;
            param["name"] = name;
            param["comment"] = comment;
            $.post("/api/ProjectHandler.ashx", param, function (res) {                
                var resobj = JSON.parse(res);
                layer.closeAll();
                parent.setProject(resobj.Data);
                location.href = "/pages/project/project.aspx?id="+resobj.Data;
            })
        }
    </script>
</body>
</html>
